#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<list>
#include<cstdlib>
#include<cmath>
#include<sstream>
#include<numeric>
#include<cstdio>
#include<cstring>
#include<stack>
#define PI acos(-1)
#define MP make_pair
#define PB push_back
#define VI vector <int>
#define PII pair <int,int>
#define LL long long
#define SET(v,i) memset(v, i, sizeof(v))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORD(i,a,b) for (int i = (a); i >= (b); i--)
#define FORN(i,a,b) for (int i = (a); i < (b); i++)
#define DOWN(i,a,b) for (int i = (a); i > (b); i--)
#define FIT(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); it++)
#define FITD(it,v) for (typeof(v.rbegin()) it = v.rbegin(); it != v.rend(); it++)
using namespace std;
const int N=100005;
const LL INF=-1000000000000000L; 
int v[N],c[N],n,m,col;
LL dp[N];
LL cal(LL a,LL b){
	for(int i=1;i<=n;i++)dp[i]=INF;
	LL ans=0,bns=0;col=0;
	for(int i=1;i<=n;i++){
		LL t=dp[c[i]]+a*v[i];
		if(c[i]!=col&&t<ans+b*v[i])t=ans+b*v[i];
		if(c[i]==col&&t<bns+b*v[i])t=bns+b*v[i];
		dp[c[i]]=max(dp[c[i]],t);
		if(t>ans){
			if(c[i]!=col)bns=ans;
			ans=t;col=c[i];
			}
		if(c[i]!=col&&t>bns)bns=t;
		}
	return max(0LL,ans);
	}
int main(){
	while(scanf("%d%d",&n,&m)!=EOF){
		for(int i=1;i<=n;i++)scanf("%d",&v[i]);
		for(int i=1;i<=n;i++)scanf("%d",&c[i]);
		for(int i=1;i<=m;i++){
			int a,b;
			scanf("%d%d",&a,&b);
			cout<<cal(a,b)<<endl;
			}
		}
    return 0;
    }
